home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / mesademos / TR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  2.0 KB  |  96 lines

  1.  
  2. /* tr.h */
  3.  
  4. /*
  5.  * Tiled Rendering library
  6.  *
  7.  * This library allows one to render arbitrarily large images with OpenGL.
  8.  * The basic idea is to break the image into tiles which are rendered one
  9.  * at a time.  The tiles are assembled together to form the final, large
  10.  * image.  Tiles can be of any size.
  11.  *
  12.  * Basic usage:
  13.  *
  14.  * 1. Allocate a tile rendering context:
  15.  *       TRcontext t = trNew();
  16.  *
  17.  * 2. Specify the final image buffer and tile size:
  18.  *       GLubyte image[W][H][4]
  19.  *       trSetup(t, W, H, (GLubyte *) image, tileWidth, tileHeight);
  20.  *
  21.  * 3. Setup your projection:
  22.  *       trFrustum(t, left, right, bottom top, nnear, ffar);
  23.  *    or
  24.  *       trOrtho(t, left, right, bottom top, nnear, ffar);
  25.  *    or
  26.  *       trPerspective(t, fovy, aspect, nnear, ffar);
  27.  *
  28.  * 4. Render the tiles:
  29.  *       do {
  30.  *           trBeginTile(t);
  31.  *           DrawMyScene();
  32.  *       } while (trEndTile(t));
  33.  *
  34.  *    You provide the DrawMyScene() function which calls glClear() and
  35.  *    draws all your stuff.
  36.  *
  37.  * 5. The image array is now complete.  Display it, write it to a file, etc.
  38.  *
  39.  * 6. Delete the tile rendering context when finished:
  40.  *       trDelete(t);
  41.  *
  42.  *
  43.  * Brian Paul
  44.  * April 1997
  45.  */
  46.  
  47.  
  48. #ifndef TR_H
  49. #define TR_H
  50.  
  51.  
  52. #ifdef _WIN32
  53. #include <windows.h>
  54. #endif
  55. #include <GL/gl.h>
  56.  
  57.  
  58. typedef struct _TRctx TRcontext;
  59.  
  60.  
  61. extern TRcontext *trNew(void);
  62.  
  63.  
  64. extern void trDelete(TRcontext *tr);
  65.  
  66.  
  67. extern void trSetup(TRcontext *tr,
  68.             GLint imageWidth, GLint imageHeight, GLubyte *image,
  69.             GLint tileWidth, GLint tileHeight);
  70.  
  71.  
  72. extern void trOrtho(TRcontext *tr,
  73.             GLdouble left, GLdouble right,
  74.             GLdouble bottom, GLdouble top,
  75.             GLdouble nnear, GLdouble ffar);
  76.  
  77.  
  78. extern void trFrustum(TRcontext *tr,
  79.               GLdouble left, GLdouble right,
  80.               GLdouble bottom, GLdouble top,
  81.               GLdouble nnear, GLdouble ffar);
  82.  
  83.  
  84. extern void trPerspective(TRcontext *tr,
  85.               GLdouble fovy, GLdouble aspect,
  86.               GLdouble zNear, GLdouble zFar );
  87.  
  88.  
  89. extern void trBeginTile(TRcontext *tr);
  90.  
  91.  
  92. extern int trEndTile(TRcontext *tr);
  93.  
  94.  
  95. #endif
  96.